<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	
	<script>
		let strs = '66'
		let ff ='66.36'
		let ff1 = '0.32'
		let ff2 = '0.52哈'
		let bool = true
		// 如何将其他类型转换为数字类型
		// 1.通过Number构造器
		console.log(Number(strs))
		// 2.通过+ -
		console.log(+strs)
		// console.log(-strs)
		// 3.取整或转小数
		// parseInt() 转换为整数 能转换就转换转不了就停止
		console.log(parseInt(strs),'parseInt')
		console.log(parseInt(ff),'parseInt')
		console.log(parseInt(ff2),'parseInt')
		// parseFloat  可以转小数 规则和parseInt一样
		console.log(parseFloat(strs),'parseFloat')
		console.log(parseFloat(ff1),'parseFloat')
		console.log(parseFloat(ff2),'parseFloat')
	// 布尔类型转换为数字类型
		console.log(Number(bool)) //true 是1
		console.log(Number(false)) //false 是0

		console.log(Number(null)) //0
		console.log(Number(undefined)) //NaN

		// 将其他类型转换为布尔
		let fs = '哈哈哈哈'
		let fs0 = ''
		let gs = 1
		let gs0 = 0

		console.log(Boolean(fs),'fs')
		console.log(Boolean(fs0),'fs')//false
		console.log(Boolean(gs),'gs')
		console.log(Boolean(gs0),'gs')//false
		console.log(Boolean(null)) //false
		console.log(Boolean(undefined)) //false

		// 将其他类型转换为字符串类型

		// toString()
		console.log(gs.toString())
		console.log(String(gs))




	</script>
</body>
</html>